package com.ssm.zhihu_ssm.controller;

import com.ssm.zhihu_ssm.entity.Answer;
import com.ssm.zhihu_ssm.service.AnswerService;
import com.ssm.zhihu_ssm.util.ReturnMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class AdminAnswerController {

    @Autowired
    private AnswerService answerService;

    @RequestMapping("/getAllAnswer")//查询所有回答
    public Map<String, Object> getAllAnswer(){
        List<Answer> answerList = answerService.getAllAnswer();
        Map<String, Object> map = ReturnMap.ReturnMapS(answerList);
        return map;
    }

    @RequestMapping("/deleteAnswerByAnswerId")//删除回答
    public Map<String, Object> deleteAnswerByAnswerId(int id){
        answerService.deleteAnswerByAnswerId(id);
        Map<String, Object> map = ReturnMap.ReturnMapS("true");
        return map;
    }

}
